<template>
  <div>
    <h3>报销记录</h3>
    <el-table :data="reimbursementRecords">
      <el-table-column prop="reimbursementdate" label="报销申请日期"></el-table-column>
      <el-table-column prop="approvedamount" label="批准金额"></el-table-column>
      <el-table-column prop="personalexpense" label="个人自付金额"></el-table-column>
      <el-table-column prop="totalcost" label="总费用"></el-table-column>
      <el-table-column prop="reimbursementstatus" label="状态"></el-table-column>
    </el-table>
  </div>
</template>

<script>
import axios from 'axios';

export default {
  data() {
    return {
      reimbursementRecords: []  // 用于存储获取到的报销记录
    };
  },
  mounted() {
    console.log('通过 $route.params 获取的用户名:', this.$route.params.username);
    this.fetchReimbursementRecords();
  },
  methods: {
    fetchReimbursementRecords() {

      axios.get(`http://localhost:8081/reimbursementRecord/getByInsuredPersonId/${this.$route.params.username}`)
          .then(response => {
            this.reimbursementRecords = response.data; // 将获取到的数据存储到 reimbursementRecords
          })
          .catch(error => {
            console.error("Error fetching reimbursement records:", error);
          });

    }
  }
};
</script>
